package com.xhrd.demo.web.controller;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;

import com.xhrd.demo.entities.DataDictionary;
import com.xhrd.demo.service.DataDictionaryService;
import com.xhrd.demo.vo.DataDictionarySearchCondition;
import com.xhrd.demo.web.validate.DataDictionaryValidator;
import com.xhrd.framework.common.util.DateUtil;
import com.xhrd.framework.web.EntityController;

/**
 * DataDictionaryController对象
 *
 * @author 修改成自己的名字
 * @version 1.0
 */
@Controller
@RequestMapping("/system/dataDictionary/*")
public class DataDictionaryController extends EntityController<DataDictionary, DataDictionarySearchCondition> {

    /**
     * @param service
     *            the service to set
     */
    @Autowired
    public void setDataDictionaryService(DataDictionaryService service) {
        setEntityService(service);
    }

    /**
     * 转换页面提交来的日期格式
     */
    @InitBinder
    protected void initBinder(WebDataBinder binder) {
        binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
        binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat(DateUtil.getDateTimePattern()), true));
    }

    public DataDictionaryController() {
        super();
        pathPrefix = "demo/";
        addValidator = new DataDictionaryValidator();
        editValidator = addValidator;
    }

}
